import java.util.BitSet;
import java.util.Random;
import java.util.Vector;

public class BitSetExample
{
  public static void main(String args[]) 
  {
    Random r = new Random(123321);
    BitSet b = new BitSet();

    for (int i = 0; i < 500000; i++)
    {
      b.set(getNextInt(r));
    }
    //System.out.println(b);

    int [] t = new int [1000000];
    for (int i = 0; i < t.length; i++)
    {
      t[i] = getNextInt(r);
    }

    long s = System.currentTimeMillis();
    for (Integer i : t)
    {
      b.get(i);
    }
    System.out.println("time: " + (System.currentTimeMillis() - s) + "ms");
  }

  static int getNextInt(Random r)
  {
    return Math.abs(r.nextInt()%1000000);
  }


}
